﻿<?php
class cSql
{
	private $db;
	
	function con($localhost, $user, $password, $database)
	{
		$this->db = new mysqli($localhost, $user, $password, $database);
		if ($this->db->connect_errno) {
			$error = "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
			throw new Exception($error);
		}
		$this->query("set names utf8;");
	}
	
	function query($query)
	{
		$result = $this->db->query($query);
		return $result;
	}
	
	function close()
	{
		$this->db->close();
	}
	
	function getAffect()
	{
		return $this->db->affected_rows;
	}

}
?>